﻿using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;

namespace CommonUtils
{
    /// <summary>
    /// 应用工具
    /// </summary>
    public static class ApplicationUtil
    {
        public static readonly string FriendlyName = AppDomain.CurrentDomain.FriendlyName;

        public static string Name => FriendlyName;

        public static readonly Process CurrentProcess = ProcessUtil.Current;

        public static readonly int PlatformBit = IntPtr.Size * 8;

        public static bool Is64BitProcess => Environment.Is64BitProcess;

        public static readonly string ProcessName = CurrentProcess.ProcessName;

        public static readonly bool IsIIS = ProcessName.ToLower().Contains("iis", "w3wp");

        public static string CurrentFolder => Environment.CurrentDirectory;

        public static readonly string ProcessPath = CurrentProcess.MainWindowTitle;

        public static DateTime StartTime { get; private set; }

        public static void InitStartTime()
        {
            StartTime = DateTime.Now;
            LogUtil.Write("初始化启动时间：" + StartTime);
        }

        public static readonly Assembly Assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault();

        public static readonly string Version = Assembly.FullName;
    }
}
